<template>
  <div style="width: 100%;">
  <div style="width: 97%;margin: 0 auto">
    <div class="search">
      <div style="margin-left: 16px;margin-top: 10px;">
        <i class="el-icon-s-custom" ></i>用药查看
      </div>
      <div class="int">
        <el-form :model="queryParams"  ref="queryForm">
          <el-date-picker
            style="width: 252px;height: 30px!important;margin-left: 20px;margin-top: 20px"
            v-model="queryParams.createTime"
            size="small"
            type="daterange"
            range-separator=" "
            start-placeholder="创建日期"
            end-placeholder="">
          </el-date-picker>
        </el-form>
      </div>
      <div class="inquire">
        <el-button type="success" style="height: 30px;display: flex;align-items: center;float:left;margin-right: 20px"
                   @click="search">
          <i  class="el-icon-search"></i>
          查询</el-button>
        <el-button style="height: 30px;display: flex;align-items: center;float:left;margin-right: 25px" @click="reset">
          <i  class="el-icon-refresh"></i>
          重置</el-button>
        <el-button style="height: 30px;display: flex;align-items: center;">
          <i  class="el-icon-refresh"></i>
          添加</el-button>
      </div>
    </div>
    <div class="list" style="overflow:hidden;">
      <p style="margin-left: 20px;margin-top: 20px">用药列表</p>
      <el-table
        :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
        stripe
        style="width: 100%"
        :row-class-name="tableRowClassName">
        <el-table-column
          prop="title"
          label="药品名称"
          align="center"
          width="260"
        >
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="服药周期"
          align="center"
          width="350"
        >
        </el-table-column>
        <el-table-column
          prop="strength"
          label="用药强度"
          align="center"
          width="260"
        >
        </el-table-column>
        <el-table-column
          prop="drugUnitName"
          label="单元"
          align="center"
          width="260"
        >
        </el-table-column>
        <el-table-column
          prop="frequency"
          label="频度"
          align="center"
          width="230"
        >
        </el-table-column>
        <el-table-column
          prop="drugNum"
          label="频次"
          align="center"
          width=""
        >
        </el-table-column>
<!--        <el-table-column-->

<!--          prop="operate"-->
<!--          align="center"-->
<!--          label="操作">-->
<!--          <template slot-scope="scope">-->
<!--            <i class="el-icon-edit-outline" style="margin-left: 20px; color: #1BD5B1; cursor:pointer;">修改</i>-->
<!--            <i class="el-icon-zoom-in" style="margin-left: 20px;color: #4196ff; cursor:pointer;" @click="editshow(scope.$index,scope.row)">查看</i>-->
<!--            <i class="el-icon-delete" style="margin-left: 20px; color: #FD3236; cursor:pointer;" @click="omit(scope.$index,scope.row)">删除</i>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <div style="position: absolute;right: 30px;bottom: 20px;">
        <!--        <pagination-->
        <!--          v-show="total>0"-->
        <!--          :total="total"-->
        <!--          :page.sync="queryParams.pageNum"-->
        <!--          :limit.sync="queryParams.pageSize"-->
        <!--          @pagination="Caselist"-->
        <!--        />-->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryParams.pageNum"
          :page-sizes="[3, 5, 10]"
          :page-size="queryParams.pagesize"
          layout=" prev, pager, next,sizes, jumper"
          :total="tableData.length">
        </el-pagination>
      </div>

    </div>
      <div class="calendar">
        <div style="margin-left: 20px;margin-top: 20px;width: 100%;overflow:hidden;">
          <div style="float:left;">用药情况</div>
          <div style="margin-left: 40%">
            <div style="float:left;">
              <div style="float:left;width: 15px;height: 2px;background: #34c112;margin-top: 9px"></div>
              <div style="border-radius: 50%;background-color: #34c112;width: 10px;height: 10px; float:left;margin-top: 5px;"></div>
              <div style="float:left;width: 15px;height: 2px;background: #34c112;margin-top: 9px;"></div>
              <div style="float:left;">已服用</div>
            </div>
            <div style="float:left;margin-left: 50px;">
              <div style="float:left;width: 15px;height: 2px;background: #1258c1;margin-top: 9px"></div>
              <div style="border-radius: 50%;background-color: #1258c1;width: 10px;height: 10px; float:left;margin-top: 5px;"></div>
              <div style="float:left;width: 15px;height: 2px;background: #1258c1;margin-top: 9px;"></div>
              <div style="float:left;">未服用</div>
            </div>
          </div>
        </div>
        <e-charts autoresize :option="option" style="height: 580px;"></e-charts>
    </div>
<!--    日历窗口-->
    <div class="calendar">
      <p>用药明细</p>
      <div style="float:left; width: 30%;">
        <el-calendar v-model="value">
        </el-calendar>
      </div>
      <div>
        列表
      </div>
    </div>
    <!--查看窗口-->
    <div class="check" v-show="look">
      <div style="width: 100%;height: 50px;background:  #eaeaea;;line-height: 50px">
        <div style="float:left;margin-left: 25px">病例信息</div>
        <div style="float:right;margin-right: 20px" @click="off">
          <i class="el-icon-close"></i>
        </div>
      </div>
      <div class="content">
        <div class="line">
          <div class="one">就诊日期</div>
          <div class="tow" v-html="Viewlist.createTime"></div>
        </div>
        <div class="line" style="background: #F8F8F8;">
          <div class="one">就诊医院</div>
          <div class="tow" v-html="Viewlist.visitHospital"></div>
        </div>
        <div class="line">
          <div class="one">就诊科室</div>
          <div class="tow" v-html="Viewlist.visitDepartment"></div>
        </div>
        <div class="line" style="background: #F8F8F8;">
          <div class="one">挂号证件</div>
          <div class="tow" v-html="Viewlist.certificateNo"></div>
        </div>
        <div class="line">
          <div class="one">医生职称</div>
          <div class="tow" v-html="Viewlist.doctorPosition"></div>
        </div>
        <div class="lines" style="background: #F8F8F8;">
          <div class="one">家族病史</div>
          <div class="tow" v-html="Viewlist.familyMedicalHistory"></div>
        </div>
        <div class="lines">
          <div class="one">个人病逝</div>
          <div class="tow" v-html="Viewlist.personalMedicalHistory"></div>
        </div>
        <div class="lines" style="background: #F8F8F8;">
          <div class="one">主诉</div>
          <div class="tow" v-html="Viewlist.chiefComplaint"></div>
        </div>
        <div class="lines">
          <div class="one">诊断</div>
          <div class="tow" v-html="Viewlist.diagnosis"></div>
        </div>
        <div class="lines" style="background: #F8F8F8;">
          <div class="one">处方</div>
          <div class="tow" v-html="Viewlist.prescription"></div>
        </div>
      </div>
    </div>
  </div>
    <div>

    </div>
  </div>
</template>

<script>
  import {Caselist,omit,examine} from "../../../api/Case/Case";
  import {importTemplate} from "../../../api/drug/drug";
  import {Medicationlist,Drugdeletion,Medicationlook,prescription} from "../../../api/pharmacy/pharmacy";

  export default {
    name: 'PatientManagement',
    data () {
      return {
        option : {
          xAxis: {
            type: 'category',
            // data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
          },
          yAxis: {
            type: 'value'
          },
          series: [
            //蓝色的
            {
              // data: [150, 230, 224, 218, 135, 147, 260, 230, 224, 218,50,90],
              data: [1,2,1.5,3,1.5,2,0,2.5,3,0,2.5,3],
              type: 'line'
            },
            //绿色的
            {
              // data: [100, 30, 24, 118, 235, 347, 200, 135, 147, 260, 230,12],
              data: [1.5,1,0,2.5,3,0.5,2,1.5,3,1.5,2,2.5],
              type: 'line'
            }
          ]
        },
        value: new Date(),
        look:false,
        // total:0,
        custIds:[],
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          createTime: undefined
        },
        time: '',
        patientgender: '',
        currentPage: 1,
        pagesize: 10,
        enable: true,
        labelPosition: 'right',
        options: [{
          value: '0',
          label: '男'
        }, {
          value: '1',
          label: '女'
        }],
        tableData: [],
        Viewlist:[{}]
      }
    },
    created(){
      this.Medicationlist()
    },
    methods: {
      // 查看
      editshow(index,row){
        this.look = true
        console.log('row',row.id)
        Medicationlook({drugId:row.id}).then(res=>{
          this.Viewlist = res.data
          console.log( this.Viewlist)
        }).catch(err=>{
          console.log(err)
        })
      },
      off(){
        this.look= false,
          this.Viewlist = [{}]
      },
      //删除
      omit(index,row){
        console.log(row)
        Drugdeletion({id:row.caId}).then(res=>{
          console.log(res)
          this.search()
        }).catch(err=>{
          console.log(err)
        })
      },
      //查询
      search(){
        this.queryParams.page = 1;
        console.log('查询')
        Medicationlist(this.addDateRange(this.queryParams)).then(res=>{
          console.log(res.rows)
          this.tableData = res.rows
        }).catch(err=>{
          console.log(err)
        })
      },
      //列表
      Medicationlist(){
        let data = this.$route.query.createorId
        console.log('参数',data)
        console.log('参数=',data.custId)
        let ooo = data.custId
        Medicationlist({createorId:ooo}).then(res=>{
          console.log('用药查看列表',res.rows )
          for (var i=0; i<res.rows.length; i++){
            console.log(res.rows[i].frequency)
            if (res.rows[i].frequency == '1'){
              res.rows[i].frequency = '每天提醒'
            }else if (res.rows[i].frequency == '2'){
              res.rows[i].frequency = '间隔提醒'
            }else if (res.rows[i].frequency == '3'){
              res.rows[i].frequency = '特殊日子'
            }else if (res.rows[i].frequency == ''){
              res.rows[i].frequency = ''
            }
          }
          this.tableData = res.rows
        }).catch(err=>{
          console.log(err)
        })
      },
      handleSizeChange (val) {
        this.pagesize = val
        console.log(`每页 ${val} 条`)
      },
      handleCurrentChange (val) {
        this.currentPage = val
        console.log(`当前页: ${val}`)
      },
      // 重置
      reset () {
        this.Medicationlist()
        this.resetForm("queryForm");
        this.queryParams.createTime = ''
      },
      tableRowClassName ({ row, rowIndex }) {
        if (rowIndex === 1) {
          return 'warning-row'
        } else if (rowIndex === 3) {
          return 'success-row'
        }
        return ''
      }
    }
  }
</script>

<style scoped lang="scss">
  .check{
    width: 700px;
    height: 780px;
    background: #FFFFFF;
    box-shadow: 0px 0px 32px 0px rgba(97,97,97,0.1);
    border-radius: 8px;
    position: absolute;
    top: -40%;
    bottom: 0;
    left: -10%;
    right:0 ;
    margin: auto;
    z-index: 10;
    overflow: hidden;
    .content{
      width: 80%;
      height: 650px;
      background: #FFFFFF;
      border: 1px solid #cdcccc;
      border-radius: 24px;
      margin: 0 auto;
      margin-top: 20px;
      overflow: hidden;

      .line{
        width: 100%;
        height: 40px;
        background: #ffffff;
        .one{
          float: left;
          width: 35%;
          height: 100%;
          line-height: 40px;
          border-right: 2px solid #eae9e9;
          text-align: center;
        }
        .tow{
          width: 65%;
          height: 40px;
          line-height: 40px;
          text-align: center;
        }
      }
      .lines{
        width: 100%;
        height: 91px;
        background: #ffffff;
        .one{
          float: left;
          width: 35%;
          height: 91px;
          line-height: 100px;
          border-right: 2px solid #eae9e9;
          text-align: center;
        }
        .tow{
          width: 65%;
          height: 91px;
          line-height: 100px;
          text-align: center;
        }
      }
    }
  }
  .submit{
    width: 80px;
    height: 30px;
    background: #009945;
    border-radius: 4px;
    color: #ffffff;
    text-align: center;
    line-height: 30px;
    font-size: 12px;
    float: left;
    cursor:pointer;
  }
  .cancel{
    width: 80px;
    float: left;
    height: 30px;
    border-radius: 4px;
    text-align: center;
    line-height: 30px;
    font-size: 12px;
    border: 1px solid #EEEEEE;
    margin-left: 20px;
    cursor:pointer;
  }
  .redact{
    width: 600px;
    height: 580px;
    background: #FFFFFF;
    box-shadow: 0px 0px 32px 0px rgba(97,97,97,0.1);
    border-radius: 8px;
    position:fixed;
    top: 50%;
    left: 50%;
    margin-left: -300px;
    margin-top: -285px;
    z-index: 10;
    .title{
      width: 100%;
      height: 40px;
      background: #e7e5e5;
      /*background:red;*/
      border-radius: 8px 8px 0px 0px;
    }
  }
  .search{
    width: 100%;
    height: 120px;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0px 4px 20px 0px rgba(51,51,51,0.08);
    margin-top: 20px;
  }
  .list{
    width: 100%;
    height: 600px;
    background: #ffffff;
    box-shadow: 0px 4px 20px 0px rgba(51,51,51,0.08);
    border-radius: 8px;
    margin-top: 20px;
    position: relative;
  }
  .calendar{
    width: 100%;
    height: 600px;
    background: #ffffff;
    box-shadow: 0px 4px 20px 0px rgba(51,51,51,0.08);
    border-radius: 8px;
    margin-top: 20px;
    position: relative;
    margin-bottom: 50px;
    overflow: hidden;
    p{
      margin-top: 15px;
      margin-left: 20px;
      font-size: 18px;
      font-family: Microsoft YaHei;
      color: #333333;
    }
  }
  .int{
    width: 28%;
    float: left;
    input{
      padding: 0px 10px;
      width: 225px;
      height: 30px;
      background: #FFFFFF;
      border: 1px solid #E8E8E8;
      border-radius: 4px;
      margin-left: 20px;
      margin-top:20px;
    }
  }
  .inquire{
    width: 40%;
    height: 50px;
    float: left;
    margin-top: 20px;
  }

</style>

